//
//  SNReturnGoodsAskAndResPondModel.m
//  app
//
//  Created by 王少宁 on 15/5/21.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "SNReturnGoodsAskAndRespondModel.H"

@implementation SNReturnGoodsAskAndRespondModel

- (instancetype)initwithDict:(NSDictionary *)dict
{
    if ([super init]) {
        _returnsReason = [NSString stringWithFormat:@"我要售后 : %@",dict[@"returnsReason"]];
        _returnReqTime = [XCommon dateWithDateline:dict[@"returnReqTime"]];
        _processTime = dict[@"processTime"];
        _adminProcess = [NSString stringWithFormat:@"客服回复 : %@",dict[@"adminProcess"]];
//        _adminProcess = @"客服回复 : 测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据数据数据数据";
        
        NSMutableArray * reasonPicArray = [[NSMutableArray alloc] init];
        for (NSDictionary * dic in dict[@"reasonPic"]) {
            [reasonPicArray addObject:dic[@"pic"]];
        }
        _reasonPic = reasonPicArray;
        
        if (_reasonPic.count == 0) {
            _isPic = NO;
        } else {
            _isPic = YES;
        }
        
        if (_adminProcess.length > 7) {
            _isAdminProcess = YES;
        } else {
            _isAdminProcess = NO;
        }
        
        _cellHeight = 50;//
        CGFloat returnsReasonLabelHeight = [XCommon heightForString:_returnsReason fontSize:13 andWidth:kLeftRectWidth];
        _cellHeight = _cellHeight+returnsReasonLabelHeight+20+10;
        if (_isPic) {
            _cellHeight = _cellHeight+65+10;
        }
        if (_isAdminProcess) {
            NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
            [paragraphStyle setLineSpacing:3.0f];//调整行间距
            CGFloat adminProcessLabelHeight = [_adminProcess boundingRectWithSize:CGSizeMake(kTopRectWidth, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13],NSParagraphStyleAttributeName:paragraphStyle} context:nil].size.height;
            _cellHeight = _cellHeight+adminProcessLabelHeight+20+10;
        }
        _cellHeight = _cellHeight+10;
    }
    return self;
}

+ (instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc] initwithDict:dict];
}

@end
    